package com.wwb.collect.controller;

import com.ruoyi.common.core.web.oldController.BaseController;
import com.wwb.collect.request.ProductListRequest;
import com.wwb.collect.service.IWwbCollectProductHandleService;
import com.wwb.collect.service.IWwbCommonService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description: 微唯宝供应链采集商品
 * @Author: j.zh
 * @Date: 2024/6/6
 * @return
 * @Version: 4.0.0
 * @ReferenceAddress: https://docs.qq.com/doc/DWkhmYmVXZXdKSURz?_t=1716964505588&u=ec35c57c0c8744f192170e729dc16c15
**/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wwb/collect/product/handle")
public class WwbCollectProductHandleController extends BaseController {

    @Resource
    IWwbCollectProductHandleService wwbCollectProductHandleService;
    @Resource
    IWwbCommonService wwbCommonService;

    /**
     * @Description: 从微唯宝采集商品
     * @Author: j.zh
     * @Date: 2024/6/15
     * @param productListRequest
     * @return
     * @Version: 4.0.0
    **/
    @PostMapping("/getList")
    public String getProductList(@RequestBody ProductListRequest productListRequest) {
        productListRequest.setAccess_token(wwbCommonService.getToken());
        // 只获取上架商品
        productListRequest.setStatus("1");
        return wwbCollectProductHandleService.getProductList(productListRequest);
    }

    /**
     * @Description: 将微唯宝商品分发至上品库
     * @Author: j.zh
     * @Date: 2024/6/15
     * @return
     * @Version: 4.0.0
     **/
    @GetMapping("/batchProcessingToDistribute")
    public String batchProcessingToDistribute() {
        return wwbCollectProductHandleService.batchProcessingToDistribute();
    }

    /**
     * @Description: 临时方法，专门处理SKU名称问题
     * @Author: j.zh
     * @Date: 2024/6/15
     * @return
     * @Version: 4.0.0
     **/
    @GetMapping("/tempHandleSkuName")
    public String tempHandleSkuName() {
        return wwbCollectProductHandleService.tempHandleSkuName();
    }
}
